Page({
  data: {
     posid: 'idle_pos',
     audible: true,
},
basic_room() {
  my.navigateTo({
    url: '../room/room'
  });
},
basic() {
  console.log('basic12')
  my.ix.readCard({
    success: (r) => {
      console.log("success", r.info.iDCard, r.info.peopleName);
      console.log(r)
      if(r.success){
        my.ix.faceVerify({
          verifyType: 'idCard',
          option: 'life',
          certNo: r.info.iDCard,
          certName: r.info.peopleName,
          success: (res) => {
            console.log('faceVerify forPay success', res);
            console.log(r.info.iDCard, r.info.peopleName);
            var per = my.getStorageSync({ key: 'personInfoList' }).data;
            per.push(r)
            console.log('res', per)
           
             // 语音功能
            my.ix.speech({
              text: '比对成功',
              success: (r) => {
                my.setStorageSync({
                  key: 'personInfoList',
                  data: per
                });
                my.navigateTo({
                  url: '../witness-contrast/status-return/status-return'
                });
              }
            });
           
          },
          fail: (res) => {
            // my.showToast({ content: JSON.stringify(r) });
            console.log('faceVerify forPay fail', res);
            // this.addResult('faceVerify forPay fail', r);
          }
        });
      }
    },
    fail: (r) => {
      console.log("fail, errorCode:" + r.error);
       my.showToast({
        type: 'fail',
        content: '请拿起身份证重新刷一次',
        duration: 3000,
        success: () => {
          // my.alert({
          //   title: 'toast 消失了',
          // });
        },
      });
    }
  });
},
  onLoad(query) {
    // 页面加载
    console.info(`Page onLoad with query: ${JSON.stringify(query)}`);
  },
  onReady() {
    // 页面加载完成
  },
  onShow() {
    // 页面显示
    console.log('认证对比。。。')
    my.setStorageSync({
      key: 'personInfoList',
      data: []
    });
    // let obj1= {name:'ch', age: 13}
    // let obj2= {name:'ch2', age: 13}
    // let obj3= {name:'ch2', age: 132}
    // let arr = [obj1, obj2, obj3]
    // // let arr = new Set([{name:'ch', age: 13}, {name:'ch', age: 13}])
    // console.log(arr)
    // let my =arr.filter((item, i, self) => {
    //   let newArr = [];
    //   arr.forEach((res, j) => {
    //     newArr.push(res.age)
    //   })
    //   console.log(newArr.indexOf(item.age))
    //   return newArr.indexOf(item.age) === i
    // })
    // console.log(my)
  },
  onHide() {
    // 页面隐藏
  },
  onUnload() {
    // 页面被关闭
  },
  onTitleClick() {
    // 标题被点击
  },
  onPullDownRefresh() {
    // 页面被下拉
  },
  onReachBottom() {
    // 页面被拉到底部
  },
  onShareAppMessage() {
    // 返回自定义分享信息
    return {
      title: 'My App',
      desc: 'My App description',
      path: 'pages/index/index',
    };
  },
});
